<template>
  <div>
    <!-- table -->
    <FilterTable
      height="250"
      ref="listModal"
      :columns="columns"
      :fetchapi="fetchApi"
      :params="fetchParams"
      :datakey="'records'"
      :dataSource="dataSource"
      :onColumnsChange="columns => (this.columns = columns)"
      :onRowSelectChange="selectChange"
      columnsRef="notification_maintain_dealerRole_01"
    ></FilterTable>

    <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">确定</el-button>
    </div>
  </div>
</template>
<script>
import { dictionary } from '@/utils/dictMixin';
import { getTcCodeByType } from '@/api/cms-api/notification/maintain/index';
import { getAllList } from '@/api/cms-api/personnelInfo/postSet/index.js';
export default {
  mixins: [dictionary],
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      columns: this.creatHeader(),
      fetchApi: null,
      fetchParams: null,
      dataSource: [],
    };
  },
  mounted() {
    this.getStation();
  },
  methods: {
    //table表头和数据源
    creatHeader() {
      return [
        {
          title: '序号',
          dataIndex: 'index',
          width: 80,
          sorter: true,
          render: props => {
            return <span>{props.row.index + 1}</span>;
          }
        },
        { title: '角色名称', dataIndex: 'text', sorter: true }
      ];
    },
    //选中
    selectChange(rows) {
      this.selectedRows = rows;
      console.log(this.selectedRows);
    },
    //保存
    saveDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows });
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    },
    async getStation(){
      const param = {
        enable: 10031001,
        orgTypes: this.value.orgTypes,
        isSendToDms: true
      }
      const res = await getAllList(param);
      let arr = new Array();
      res.data.forEach(t => {
        let data = {
          value: t.stationDictCode,
          text: t.stationName,
        }
        arr.push(data);
      })
      this.dataSource = arr;
    }
  }
};
</script>

<style lang="less" scoped></style>
